package main

import (
	"time"
	"log"
)

func main() {

	ch := make(chan int)

	log.Println("start...")

	timeOut := time.After(5 * time.Second)
	timeTick := time.Tick(1 * time.Second)

	go func() {
		time.Sleep(12 * time.Second)
		ch <- 1
	}()

	Timeout:
	for {
		select {
		case val := <-ch:
			log.Println(val)
		case <- timeOut:
			log.Println("timeout....")
			break Timeout
		case <- timeTick:
			log.Println("timeTick.....0")
		}
	}


	log.Println("end...")
	
}
